﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WorkflowCore.Service.Dto.Fundamentals;
using WorkflowCore.Service.Dto.Input;
using WorkflowCore.Service.Service;

namespace Workflow_Core_API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkflowController : ControllerBase
    {
        private readonly IWorkflowServer server;
        private readonly GetWorkflowData data;

        public WorkflowController(IWorkflowServer server, GetWorkflowData data)
        {
            this.server = server;
            this.data = data;
        }

        /// <summary>
        /// 定义流程
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        //[HttpPost]
        //public Results_<int> AddWorkflowData([FromBody] WorkflowDefinitionInput input)
        //{
        //    return server.AddDefinition(input);
        //}
        /// <summary>
        /// 流程发起
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Results_<string> StartWorkflowData([FromBody] WorkflowLaunchInput input)
        {
            return server.StartWorkflow(input);
        }
        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Results_<int> UpAuditData([FromBody] WorkflowAuditInput input)
        { 
            return server.UpAudit(input);
        }
        /// <summary>
        /// 驳回发起
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Results_<int> UpDateRerectData([FromBody] WorkflowAuditInput input)
        {
            return server.UpRejectData(input);
        }
    }
}
